import Vue from 'vue'
import axios from 'axios'

axios.defaults.baseURL = 'http://localhost:3001'

axios.interceptors.request.use(function (config) {
	if(window.sessionStorage.getItem('token')){
		config.headers.Authorization = window.sessionStorage.getItem('token')
	}
	return config
}, function (err) {
	console.log(err)
})

axios.interceptors.response.use(function (res) {
	return res.data
}, function (err) {
	console.log(err)
})

Vue.prototype.$http = axios